import 'dart:async';

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:xvideos/hj_model/video_model.dart';
import 'package:xvideos/hj_utils/api_service/tag_service.dart';

class CommunityTagController extends GetxController with GetTickerProviderStateMixin {
  final scrollCtr = ScrollController();
  double? offset;
  bool isPinned = false;
  late TagsBean model;
  StreamController<bool> showAppCtr = StreamController.broadcast();
  late final TabController mainTabCtr = TabController(length: sorts.length, vsync: this);

  RxBool isLoadingFollow = false.obs;
  final sorts = [2, 1, 4];//排序类型 1:最新上架 2:最多收藏 3:本月最热 4:最多观看

  @override
  void onInit() {
    model = Get.arguments;

    super.onInit();
  }

  @override
  onReady() async {
    super.onReady();
    final newsType = model.newsType;
    final res = await TagService.fetchTagInfo(model.id ?? '');
    if (res != null) {
      model = res;
      model.newsType = newsType;
    }
    update();
  }

  @override
  void onClose() {
    showAppCtr.close();

    mainTabCtr.dispose();
    super.onClose();
  }
}
